package com.lee.day01;

import com.lee.channel.OutputChannel;
import com.lee.model.OrderModel;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Description TODO
 * @Author winston
 * @DateTime 2022/8/25
 */
//@Component
public class Producer {

    @Resource
    private OutputChannel outputChannel;

    public void sendMessage(OrderModel orderModel) {
        Message<OrderModel> modelMessage = MessageBuilder.withPayload(orderModel).setHeader("type", "order").build();
        outputChannel.orderChannel().send(modelMessage);
    }

    public void sendOaMessage(OrderModel orderModel) {
        Message<OrderModel> modelMessage = MessageBuilder.withPayload(orderModel).setHeader("type", "order").build();
        outputChannel.oaChannel().send(modelMessage);
    }
}
